<?php

namespace App\Modules\Doctor\Models;


use App\Modules\Admin\Models\AdminUsers;
use Illuminate\Database\Eloquent\Model;

/**
 * Class Graphic 医生
 * @package App\Modules\Task\Models
 */
class Doctor extends Model
{
    protected $table = 'doctor';

    protected $fillable = ['id', 'admin_user_id', 'name', 'gender', 'age', 'institution_id', 'is_consulting', 'is_booking', 'department_id', 'contact', 'good_at', 'signature', 'certificate', 'position', 'working_time', 'background', 'photo', 'tag','created_at', 'updated_at', 'status'];

    public function consultingTime() {
        return $this->hasOne(ConsultingTime::class);
    }

    public function adminUsers() {
        return $this->belongsTo(AdminUsers::class,'admin_user_id');
    }

    static function getList($param)
    {
        return self::where('status','>=',0)->paginate($param['size']);
    }


    static function getDetails($id)
    {
        return self::where('id',$id)->first();
    }

    static function add($param)
    {
        // TODO check
        return self::create($param);
    }

    static function findById($id) {
        return self::find($id);
    }

    static function getByAdminIds($ids)
    {
        return self::whereIn('admin_user_id',$ids)->get();
    }
}